<!--
 * @Author: HaiF
 * @Date: 2020-12-03 00:02:13
 * @LastEditTime: 2020-12-03 00:23:02
 * @LastEditors: your name
 * @Description: 查询条件
 * @FilePath: \adminPC\src\views\user\widget\findBox.vue
 * @可以输入预定的版权声明、个性签名、空行等
-->

<template>
  <JForm :form-config="dynamicValidateForm" @handleBoxEvent="handleBoxEvent" />
</template>

<script>
import JForm from '@/components/JForm'
import { mapActions, mapState } from 'vuex'

export default {
  components: { JForm },
  props: {},
  data() {
    const userInfo = [
      {
        name: 'idNo',
        label: '证件',
        type: 'string',
        required: false
      },
      {
        name: 'loginId',
        label: '登录名',
        type: 'string',
        required: false
      },
      {
        name: 'nickName',
        label: '昵称',
        type: 'string',
        required: false
      },
      {
        name: 'orgId',
        label: '部门ID',
        type: 'string',
        required: false
      },
      {
        name: 'telephone',
        label: '电话',
        type: 'string',
        required: false
      },
      {
        name: 'userName',
        label: '用户姓名',
        type: 'string',
        required: false
      },
      {
        name: 'userType',
        label: '用户类型',
        type: 'option',
        required: false,
        placeholder: '0=系统用户,1=普通用户,2=单位用户,3=会员,9=匿名用户',
        config: {
          options: {}
        }
      }
    ]
    return {
      userInfo
    }
  },
  computed: {
    ...mapState('dictionary', ['dic']),
    /* option数据处理 */
    dynamicValidateForm() {
      const data = this.userInfo
      const result = []
      data.forEach(i => {
        const { type } = i
        if (type === 'option') {
          i.config.options = this.filterOption(i)
        }
        result.push(i)
      })
      return result
    },
    userTypeOption() {
      const data = this.dic['USER_TYPE'] || []
      const result = []
      data.forEach(i => {
        const { code, name } = i
        result.push({
          label: name,
          value: +code
        })
      })
      return result
    }
  },
  watch: {},
  created() {
    this.getDictListByType('USER_TYPE')
  },
  mounted() {},
  methods: {
    ...mapActions('dictionary', ['getDictListByType']),
    filterOption(item) {
      const key = item.name
      return this[`${key}Option`]
    },
    handleBoxEvent(emitObj) {
      this.$emit('handleBoxEvent', emitObj)
    }
  }
}
</script>
<style lang="scss" scoped>
.wrapper{
   padding: 0px;
   margin: 0px;
}
</style>
